package com.hnkywl.sts.action.report;

import com.hnkywl.sts.entity.organ.Khh;
import com.hnkywl.sts.service.organ.KhhService;
import com.hnkywl.sts.service.report.YhckService;
import net.ruixin.web.struts2.SimpleActionSupport;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Calendar;
import java.util.Date;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 13-6-14
 * Time: 下午4:48
 * To change this template use File | Settings | File Templates.
 */
@Namespace("/report/yhck")
public class YhckAction extends SimpleActionSupport {
    private Long gsId;
    private Date date;
    private Date startDate;
    private String zh;
    private int page;
    private int rows;
    private YhckService yhckService;
    private KhhService khhService;
    private Date endDate;
    private Long zhlx;


    @Action("yhck")
    public String cwsfc() {
        date = new Date();
        return SUCCESS;
    }

    @Action("yhckList")
    public void yhckList() {
        String json = yhckService.yhckList(gsId,new Date(date.getTime()),zhlx,page,rows);
        renderJson(json);
    }

    @Action("yhck_zkzh_mx")
    public String yhckCkzhMx(){
//        date = new Date();
        Calendar cal = Calendar.getInstance();
        cal.setTime(endDate);
        cal.set(Calendar.DAY_OF_MONTH, 1);
        startDate = cal.getTime();
        return SUCCESS;
    }

    @Action("yhckmxList")
    public void yhckmxList() {
        Khh khh = khhService.findKhhByZh(zh);
        String json = yhckService.yhckmxList(gsId,khh.getId(),new Date(startDate.getTime()), new Date(endDate.getTime()), page, rows);
        renderJson(json);
    }

    //=================setter getter==============

    public Long getGsId() {
        return gsId;
    }

    public void setGsId(Long gsId) {
        this.gsId = gsId;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getRows() {
        return rows;
    }

    public void setRows(int rows) {
        this.rows = rows;
    }

    public String getZh() {
        return zh;
    }

    public void setZh(String zh) {
        this.zh = zh;
    }

    public Date getStartDate() {
        return startDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public Long getZhlx() {
        return zhlx;
    }

    public void setZhlx(Long zhlx) {
        this.zhlx = zhlx;
    }

    //=================setter===================
    @Autowired
    public void setYhckService(YhckService yhckService) {
        this.yhckService = yhckService;
    }
    @Autowired
    public void setKhhService(KhhService khhService) {
        this.khhService = khhService;
    }
}
